<?php
use think\migration\Migrator;
use think\migration\db\Column;

class CreateM2vTasks extends Migrator
{
    public function change()
    {
        $this->table('m2v_tasks', ['engine' => 'InnoDB'])
            ->addColumn('user_id', 'integer', ['comment' => '用户ID'])
            ->addColumn('task_id', 'string', ['limit' => 64, 'comment' => '远程任务ID'])
            ->addColumn('product_link', 'string', ['limit' => 255, 'null' => true, 'comment' => '产品链接'])
            ->addColumn('file_ids', 'text', ['null' => true, 'comment' => '素材文件ID，JSON数组'])
            ->addColumn('product_name', 'string', ['limit' => 255, 'null' => true, 'comment' => '产品名称'])
            ->addColumn('product_description', 'text', ['null' => true, 'comment' => '产品描述'])
            ->addColumn('aspect_ratio', 'string', ['limit' => 10, 'default' => '9:16', 'comment' => '视频比例'])
            ->addColumn('language', 'string', ['limit' => 10, 'default' => 'en', 'comment' => '语言'])
            ->addColumn('voice_id', 'string', ['limit' => 64, 'null' => true, 'comment' => '音色ID'])
            ->addColumn('caption_id', 'string', ['limit' => 64, 'null' => true, 'comment' => '字幕样式ID'])
            ->addColumn('aiavatar_id', 'string', ['limit' => 64, 'null' => true, 'comment' => '数字人ID'])
            ->addColumn('video_length_type', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '视频长度类型'])
            ->addColumn('endcard_file_id', 'string', ['limit' => 64, 'null' => true, 'comment' => '片尾文件ID'])
            ->addColumn('logo_file_id', 'string', ['limit' => 64, 'null' => true, 'comment' => 'Logo文件ID'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '状态：0待处理,1处理中,2已完成,3失败'])
            ->addColumn('video_url', 'string', ['limit' => 255, 'null' => true, 'comment' => '视频URL'])
            ->addColumn('error_msg', 'string', ['limit' => 255, 'null' => true, 'comment' => '错误信息'])
            ->addColumn('points_consumed', 'integer', ['default' => 0, 'comment' => '消耗积分'])
            ->addColumn('create_time', 'timestamp', ['default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
            ->addColumn('update_time', 'timestamp', ['null' => true, 'comment' => '更新时间'])
            ->addIndex(['user_id'])
            ->addIndex(['task_id'])
            ->create();
    }
} 